package com.iespring.controller.app.admin;

import com.iespring.bean.app.user.vo.WxCategoryVo;
import com.iespring.bean.app.user.vo.WxDetailVo;
import com.iespring.bean.common.BasePageInfo;
import com.iespring.bean.common.BaseRespVo;
import com.iespring.bean.common.CommonData;
import com.iespring.service.app.WxGoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author xD
 * @since 2022/12/31 21:42
 */
@RestController
@RequestMapping("wx/goods")
public class WxGoodsController {
    @Resource
    private WxGoodsService wxGoodsService;

    @GetMapping("count")
    public BaseRespVo count() {
        Integer count = wxGoodsService.count();
        return BaseRespVo.ok(count);
    }

    @GetMapping("category")
    public BaseRespVo category(@RequestParam("id") Integer id) {
        WxCategoryVo wxCategoryVo = wxGoodsService.category(id);
        return BaseRespVo.ok(wxCategoryVo);
    }

    @GetMapping("list")
    public BaseRespVo list(BasePageInfo pageInfo) {
        CommonData commonData = wxGoodsService.list(pageInfo);
        return BaseRespVo.ok(commonData);
    }

    @GetMapping("detail")
    public BaseRespVo detail(Integer id) {
        WxDetailVo wxDetailVo = wxGoodsService.detail(id);
        return BaseRespVo.ok(wxDetailVo);
    }

    @GetMapping("related")
    public BaseRespVo related(Integer id) {
        CommonData commonData = wxGoodsService.related(id);
        return BaseRespVo.ok(commonData);
    }

}
